import 'package:flutter/material.dart';

import 'add_blog.dart';

class BlogListPage extends StatelessWidget {
  final parentContext;

  BlogListPage(this.parentContext);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '花生皮博客',
      home: BlogListWidget(this.parentContext),
    );
  }
}

class BlogListWidget extends StatefulWidget {
  final parentContext;

  BlogListWidget(this.parentContext);

  @override
  createState() => new _BlogListState();
}

class _BlogListState extends State<BlogListWidget> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("博客"),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: gotoAddBlogPage,
        child: Icon(Icons.add),
      ),
    );
  }

  gotoAddBlogPage() {
    Navigator.push(widget.parentContext,
        MaterialPageRoute(builder: (context) => AddBlogPage()));
  }
}
